import { useCurrentMember, useData, useWeapp } from "@sker/runtime";
import { toSuccess, useTransaction } from "@sker/core";
import { WxMember } from "@sker/entities";
import { z } from "zod";

/**
 * 获取微信小程序的手机号
 */
export default async () => {
    const input = z.object({
        code: z.string()
    })
    const body = input.parse(useData())
    return await useTransaction(async m => {
        const app = await useWeapp();
        const phone = await app.getPhoneNumber(body.code);
        return toSuccess(phone)
    })
}